import emojiData from './emojiData.js'
export function getFaceList(panelIndex) {
	let arr = [];
	for (let txt in emojiData) {
		if (emojiData[txt][2] == panelIndex) { // 找到对应面板的显示。
			if (emojiData[txt][1]) { // 保证该表情未下线
				let s = getFaceUrl(emojiData[txt]);
				s = `<a href="javascript:;" title="${txt}"> <img data-src="${s}"></a>`;
				arr.push(s);
			}
		}
	}
	return arr;
}

export function getFaceUrl(emoji) {
	return `https://file.mjcelaine.top/biaoqingbao/demo/${emoji[2]}.png`
}

export function text2pic(txt) {
	if (!txt) {
		return '';
	}
	txt = txt.replace(/\[([^\]]+)\]/g, function(v1, v2) {
		//v1： [买买买]   v2：买买买
		let d = emojiData[v2];

		return d ?
			'<img class="quan_icon_emoji" style="width:20px;height:20px;object-fit:cover;vertical-align:bottom;" src="' +
			getFaceUrl(d) + '" />' : v1;
	});
	return txt;
}

export function getName(panelIndex) {
	for (let txt in emojiData) {
		if (emojiData[txt][2] == panelIndex) { // 找到对应面板的显示。
			return emojiData[txt][0]
		}
	}
	return '异常'
}
